# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=shhgit
pkgver=67.bac0c7d
pkgrel=1
pkgdesc='Find committed secrets and sensitive files across GitHub, Gists, GitLab and BitBucket or your local repositories in real time.'
arch=('x86_64' 'aarch64')
groups=('blackarch' 'blackarch-recon')
url='https://github.com/eth0izzle/shhgit'
license=('MIT')
makedepends=('git' 'go')
source=("git+https://github.com/eth0izzle/$pkgname.git")
sha512sums=('SKIP')
install='shhgit.install'

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

build() {
  cd $pkgname

  GOPATH="$srcdir" go mod download
  GOPATH="$srcdir" go build \
    -trimpath \
    -buildmode=pie \
    -mod=readonly \
    -modcacherw \
    -ldflags "-s -w" \
    -o $pkgname .
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 755 $pkgname "$pkgdir/usr/bin/$pkgname"
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md

  cp -a --no-preserve=ownership images/ "$pkgdir/usr/share/doc/$pkgname"
  cp -a --no-preserve=ownership www/ config.yaml "$pkgdir/usr/share/$pkgname"
}

